﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ttlang.compiler
{
    public class RandomStack<T> : List<T> where T : class//T必须是引用，禁止其它玩意儿
    {
        public void Push(T value)
        {
            this.Add(value);
        }
        public T Pop()
        {
            if (this.Count == 0)
                return null;

            T v = this[this.Count - 1];
            this.RemoveAt(this.Count - 1);
            return v;
        }
        public T Peek()
        {
            return this[this.Count - 1];
        }
        public T Peek(int at)
        {
            return this[this.Count - 1 - at];
        }
    }
}
